<?php

namespace app\common\model;

use think\Model;


class Star extends Model
{
    // 表名
    protected $name = 'star';


    public function getCreatetimeAttr($value)
    {
        $status = date('Y-m-d', $value);
        return $status;
    }



    //根据分类ID获取指定数据
    public static function getList($data)
    {
        $info=self::order('weigh', 'desc');
        if(!empty($data['keywords'])){
            $info->where('title','like','%'.$data['keywords'].'%');
        }
        $list=$info->field('id,name,describe,createtime,weigh,image')->order(['weigh'=>'desc','createtime'=>'desc'])->paginate(15,false,['page'=>$data['page']]);
        return $list;
    }
    /*
    * 读取分页
    * @param string $type   指定类型
    * @param string $status 指定状态
    * @return array
    */
    public static function details($id)
    {
        $list=self::where(['id'=>$id])->find();
        return $list;
    }


}
